layui.use(['jquery','form', 'ax','admin','layedit', 'laydate','formSelects'], function(){
    var $ =layui.jquery
    var form = layui.form
    var layer = layui.layer
    var layedit = layui.layedit
    var laydate = layui.laydate
    var $ax = layui.ax;
    var admin = layui.admin;
    var formSelects = layui.formSelects;

    var sframeId=$("#sframeId").val();
    alert(sframeId);
    //初始化所有的日程框架项时间段
    formSelects.config('sformLimit', {
        searchUrl: Feng.ctxPath + "/myScheduleFrame/showSframeItemBySframeIdList?sframeId="+sframeId,
        keyName: 'timeLimit',
        keyVal: 'sframeItemId'
    });


    // 表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        alert(JSON.stringify(data));
        var sformId=data.field.sformId
        alert(sformId);
        console.log(data)
        var ajax = new $ax(Feng.ctxPath + "/myScheduleFormItem/saveSfromItem", function (data) {
            Feng.success("日程创建成功！");

            //传给上个页面，刷新table用
            admin.putTempData('formOk', true);
           //关掉对话框
            admin.closeThisDialog();
            //去到显示该日程表
            /*parent.location.href="/myScheduleForm/checkScheduleForm2?sformId="+sformId;*/
            /*跳到插件的日程表*/
            parent.location.href="/myScheduleForm/checkScheduleForm?sformId="+sformId;

        }, function (data) {
            Feng.error( data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();

        //添加 return false 可成功跳转页面
        return false;
    });



    function showData(){
/*        lay('.datatime').each(function () {
            //时间范围
            laydate.render({
                elem: this
                ,type: 'datetime'

            });

        });*/

    }
    showData();


});
